// splice 如何删除数组中的指定元素
const array = [
  { name: "hugo", age: 18 },
  { name: "bigo", age: 20 },
];

function cutArray(sourceArray, target) {
  sourceArray.forEach((item, index) => {
    if (item.name === target) {
      sourceArray.splice(index, 1);
    }
  });
  return sourceArray;
}

const result = cutArray(array, "bigo");
console.log(result);
